Fix invalid YAML syntax in agent-fix.yml workflow - #32
Conversation
📝 WalkthroughWalkthroughThe workflow updates the ChangesIssue Comment Formatting
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/agent-fix.yml:
- Around line 71-89: Update the success and failure comment-body construction in
the workflow to avoid preserving YAML indentation in posted Markdown. Build each
message from unindented line strings joined with "\n" (or use an existing safe
dedent helper), while preserving the current interpolated values, formatting,
and fallback messages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f5c5b7fe-2064-465c-ae16-6c7e5cd51be6
📒 Files selected for processing (1)
.github/workflows/agent-fix.yml
| commentBody = `Hello @${issuee}, | ||
|
|
||
| I have successfully fixed the issue! 🎉 | ||
| I have successfully fixed the issue! 🎉 | ||
|
|
||
| A Pull Request has been created with the changes: | ||
| 🔗 **[Pull Request](${prUrl})** | ||
| A Pull Request has been created with the changes: | ||
| 🔗 **[Pull Request](${prUrl})** | ||
|
|
||
| **Run ID:** \`${runId}\` | ||
| **Message:** ${message}`; | ||
| **Run ID:** \`${runId}\` | ||
| **Message:** ${message}`; | ||
| } else { | ||
| commentBody = `Hello @${issuee}, | ||
|
|
||
| I attempted to fix this issue automatically but encountered a problem. | ||
| I attempted to fix this issue automatically but encountered a problem. | ||
|
|
||
| **Outcome:** \`${outcome || 'unknown/failed'}\` | ||
| **Message:** ${message || 'No additional message was provided.'} | ||
| **Outcome:** \`${outcome || 'unknown/failed'}\` | ||
| **Message:** ${message || 'No additional message was provided.'} | ||
|
|
||
| Please check the GitHub Actions workflow logs for more details.`; | ||
| Please check the GitHub Actions workflow logs for more details.`; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Avoid leaking YAML indentation into the posted comments.
The spaces required to indent the YAML block scalar are preserved inside these template literals. Consequently, the generated comment’s body lines become an indented Markdown code block, so the PR link and bold fields will render incorrectly. Build each body from an array joined with "\n" (or apply a safe dedent helper) so the YAML indentation does not become comment content.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/agent-fix.yml around lines 71 - 89, Update the success and
failure comment-body construction in the workflow to avoid preserving YAML
indentation in posted Markdown. Build each message from unindented line strings
joined with "\n" (or use an existing safe dedent helper), while preserving the
current interpolated values, formatting, and fallback messages.
Problem
.github/workflows/agent-fix.ymlfails to run at all, with GitHubreporting:
Root cause
The
Post Comment on Issuestep uses a YAML block scalar (script: |)whose indentation baseline is set by its first line at 12 spaces.
Several lines inside the two JS template literals (the success/failure
comment bodies) were written at column 0 to keep the rendered GitHub
comment clean:
Any non-blank line with less indentation than the block's baseline
terminates the block scalar early. Since these lines had 0 indentation
against a 12-space baseline, YAML stopped parsing the script block
mid-way through, producing the syntax error and preventing the
workflow from running at all — not just failing a step, but failing
to even start.
Fix
Indented every non-blank line of both template literals to 12 spaces
so they stay inside the block scalar. This is purely a YAML-level fix:
YAML strips exactly the block's base indent from each line when
extracting the string, so the actual comment text posted to issues is
byte-identical to before.
Verified
Note
This fixes the workflow file's validity so it can run at all. I
wasn't able to trigger a real
issues: opened/labeledevent with therequired
ANTHROPIC_API_KEY/GITHUB_TOKENsecrets to test fullruntime behavior — recommend watching the next real trigger (or firing
a test issue with the
agent-fixlabel) to confirm it completesend-to-end.
Summary by CodeRabbit